package com.wust.smartcity.autotask.server.common.config;


import com.wust.smartcity.common.interceptors.ContextHandlerDefaultInterceptor;
import com.wust.smartcity.common.util.MyMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.util.List;

/**
 * Created by wust on 2019/6/12.
 */
@SpringBootConfiguration
public class WebMvcConfiguration extends WebMvcConfigurationSupport {

    @Autowired
    private MyMessageConverter myMessageConverter;

    @Bean
    public ContextHandlerDefaultInterceptor interceptor() {
        return new ContextHandlerDefaultInterceptor("");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor());
    }

    @Override
    protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        myMessageConverter.configureMessageConverters(converters);
    }
}
